//
//  DSZWDYZViewController.m
//  7.13苏宁框架
//
//  Created by app05 on 15/7/27.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZWDYZViewController.h"

#import "DSZMoreView.h"
#import "DSZMainViewController.h"
#import "HomeViewController.h"
#import "DSZShopViewController.h"
#import "DSZYZGZViewController.h"
@interface DSZWDYZViewController ()<tableViewIndexPathRowDelegate>
@property (weak, nonatomic) IBOutlet UIView *btnView;
- (IBAction)roteBtn;
@property (weak, nonatomic) IBOutlet UIView *moneyView;

@property (weak, nonatomic) IBOutlet UIView *indexView;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btn0;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
- (IBAction)btn:(UIButton *)sender;
@property(nonatomic,weak)UIView *moreView;
@property(nonatomic,assign)BOOL flag;
@property(nonatomic,weak)UIButton *selectedBtn;

- (IBAction)back;

- (IBAction)more;
@end

@implementation DSZWDYZViewController
-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.alpha=0;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.moneyView.alpha=0;
    self.btnView.alpha=0;
//    for (UIButton *button in self.btn0) {
//        if (button.tag==0) {
//            button.selected=YES;
//            self.selectedBtn=button;
//            self.selectedBtn.tintColor=[UIColor clearColor];
//        }
//    }
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)back {
    //DSZMainHeaderView *main=[[DSZMainHeaderView alloc]init];
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (IBAction)more {
    if (!self.flag) {
        DSZMoreView *more=[DSZMoreView moreView];
        more.delegate=self;
        more.frame=CGRectMake(185, 65, 146, 186);
        self.moreView=more;
        [self.view addSubview:self.moreView];
        self.flag=YES;
    }
    else
    {
        [self.moreView removeFromSuperview];
        self.moreView=nil;
        self.flag=NO;
    }
    
}
-(void)dszMoreViewWithIndexRow:(NSInteger)indexPathRow
{
    if (indexPathRow==0) {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DSZMainViewController *main=[story instantiateViewControllerWithIdentifier:@"main"];
        //DSZMainViewController *main=[[DSZMainViewController alloc]init];
        [self presentViewController: main animated:NO completion:nil];
    }else if (indexPathRow==1)
    {}
    else if (indexPathRow==2)
    {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        
        DSZShopViewController *shop=[story instantiateViewControllerWithIdentifier:@"shop"];
        [self.navigationController pushViewController:shop animated:NO];
        self.flag=YES;
        [self more];
        self.navigationController.navigationBar.alpha=1;
        DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
        [main hiddenMainTabbar:YES];
    }else if (indexPathRow==3)
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
    
}

- (IBAction)btn:(UIButton *)sender {
    
//    self.selectedBtn.selected=NO;
//    self.selectedBtn.tintColor=[UIColor colorWithRed:-0/255 green:122/255 blue:1 alpha:1];
//    UIButton *button=(UIButton *)[sender viewWithTag:sender.tag];
//    button.selected=YES;
//    self.selectedBtn=button;
//    self.selectedBtn.tintColor=[UIColor clearColor];
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.2];
    
    self.indexView.frame=CGRectMake(160*sender.tag, 45, 169, 2);
    
    self.scrollView.contentOffset=CGPointMake(320*sender.tag, 0);
    
    [UIView commitAnimations];
    
    if (sender.tag==1) {
        self.moneyView.alpha=1;
    }
    self.btnView.alpha=1;
    
}
- (IBAction)roteBtn {
    
    DSZYZGZViewController *yzgz=[[DSZYZGZViewController alloc]init];
    [self.navigationController pushViewController:yzgz animated:YES];
}
@end
